package com.wuseguang.springcloud.controller;


import com.wuseguang.springcloud.Filter.RequestParameterWrapper;
import com.wuseguang.springcloud.service.StudentsLeaveSchoolService;
import com.wuseguang.springcloud.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 学生放学表 前端控制器
 * </p>
 *
 * @author 
 * @since 2020-07-27
 */
@RestController
@RequestMapping("/jurisdiction")
public class StudentsLeaveSchoolController {


    private Logger logger = LoggerFactory.getLogger(this.toString());
    @Autowired
    private StudentsLeaveSchoolService studentsLeaveSchoolServiceImpl;

    /**
     * 查询班级学生放假详情
     * @param request
     * @param classId 班级id
     * @return
     */
    @RequestMapping("/findStudentsLeaveSchool")
    public Result findStudentsLeaveSchool(RequestParameterWrapper request,
                                          @RequestParam("classId") Integer classId,
                                          @RequestParam(value = "findDate",required = false) String findDate){
        logger.info("查询班级学生放假详情 classId = {}",classId);
        return studentsLeaveSchoolServiceImpl.findStudentsLeaveSchool(classId,findDate);
    }


    /**
     *  添加学生的放假记录
     * @param request
     * @param studentId 学生id
     * @param classId 班级id
     * @param state 1放学，2留校
     * @param date 放学或者留校时间
     * @return
     */
    @RequestMapping("/addStudentsLeaveSchool")
    public Result addStudentsLeaveSchool(RequestParameterWrapper request,
                                         @RequestParam("studentId") Integer [] studentId,
                                         @RequestParam("classId") Integer classId,
                                         @RequestParam(value = "state",required = false,defaultValue = "1") Integer state,
                                         @RequestParam(value = "date" ) String date){
        logger.info("添加学生的放假记录 ");
        //教师名称
        String teacherName = request.getParam("teacherName");
        return studentsLeaveSchoolServiceImpl.addStudentsLeaveSchool(studentId,classId,teacherName,state,date);
    }

}

